@tool
class_name Guard_EntityDataAttribute_Bool
extends Guard

@export var attribute_name:String
@export var target_value:bool

func is_satisfied(transition:Transition,state:State) -> bool:
	var entity:Entity = state.chart.get_expression_property("Entity")
	if not entity or not entity.entity_data:
		return false
	var attr:Attribute = entity.entity_data.find_attribute(attribute_name)
	if not attr:
		return false
	if typeof(attr.get_value()) not in [TYPE_BOOL]:
		return false
	return attr.get_value() == target_value

func _init() -> void:
	if Engine.is_editor_hint():
		resource_local_to_scene = true
